//
//  LGPatientDetailFollowupCell.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/9/22.
//

#import "LGPatientDetailFollowItemCell.h"

@interface LGPatientDetailFollowItemCell()
/**   */
@property (nonatomic , strong)UILabel *percentLabel;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;

@end

@implementation LGPatientDetailFollowItemCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.contentView.cornerRidus = 3;
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self.contentView addBorder:@"#EEEEEE" lineWidth:1 cornerRidus:3];
        [self.contentView addSubview:self.percentLabel];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.dateLabel];
        [self.percentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.equalTo(self.contentView);
            make.width.equalTo(@(viewPix(40)));
            make.height.equalTo(@(14));
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(viewPix(14));
            make.left.equalTo(self.contentView).offset(viewPix(12));
            make.right.equalTo(self.contentView).offset(-viewPix(12));
        }];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(5));
            make.left.right.equalTo(self.titleLabel);
        }];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.dateLabel.text = LGNSString(dataDic[@"date"]);
    NSString *warn = LGNSString(dataDic[@"warn"]);
    CGFloat warnW = [warn textWidthWithFont:LGFont(12) maxHeight:14]+10;
    warnW = (warnW>viewPix(100))?viewPix(100):warnW;
    self.percentLabel.text = warn;
    [self.percentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(warnW));
    }];
    self.percentLabel.hidden = [warn isEmptyString]?YES:NO;
}

-(void)setIsSelect:(BOOL)isSelect{
    _isSelect = isSelect;
    if (isSelect == YES) {
        [self.contentView addBorder:@"#5E8EF5" lineWidth:1 cornerRidus:3];
        self.contentView.backgroundColor = [UIColor colorWithString:@"#E5F1FF"];
        self.titleLabel.textColor = [UIColor colorWithString:@"#5E8EF5"];
        self.dateLabel.textColor = [UIColor colorWithString:@"#5E8EF5"];
    }else{
        [self.contentView addBorder:@"#EEEEEE" lineWidth:1 cornerRidus:3];
        self.contentView.backgroundColor = [UIColor colorWithString:@"#FFFFFF"];
        self.titleLabel.textColor = [UIColor colorWithString:@"#333333"];
        self.dateLabel.textColor = [UIColor colorWithString:@"#999999"];
    }
}

#pragma mark
#pragma mark ====> 创建控件
-(UILabel *)percentLabel{
    if(!_percentLabel){
        _percentLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _percentLabel.backgroundColor = [UIColor colorWithString:@"#5E8EF5"];
        _percentLabel.cornerRidus = 3;
    }
    return _percentLabel;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _titleLabel;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}


@end
